package com.sky.utils;

import com.sky.properties.MapProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@Slf4j
@Component
public class MapUtil {

    private static MapProperties mapProperties;

    @Autowired
    public MapUtil (MapProperties mapProperties){
        MapUtil.mapProperties = mapProperties;
    }

    public static String returnShopLocation(){
        return "https://api.map.baidu.com/geocoding/v3/?" +
                "address=" + mapProperties.getAddress()+
                "&output=json&" +
                "&ak=" + mapProperties.getAk()+
                "&callback=showLocation";
    }
    public static String returnBuyerLocation(String buyerLocation){
        return "https://api.map.baidu.com/geocoding/v3/?" +
                "address=" + buyerLocation+
                "&output=json&" +
                "ak=" + mapProperties.getAk()+
                "&callback=showLocation";
    }

    public static String ridingRoute(String shopLocation, String buyerLocation){
        return "https://api.map.baidu.com/direction/v2/riding?" +
                "origin=" +shopLocation+
                "&destination=" +buyerLocation+
                "&ak="+mapProperties.getAk();
    }


}



